package cn.eeepay.framework.dao;

import cn.eeepay.framework.db.pagination.Page;
import cn.eeepay.framework.model.AccountAddress;
import cn.eeepay.framework.model.AddressMapping;
import cn.hutool.core.util.StrUtil;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.jdbc.SQL;

import java.util.List;
import java.util.Map;

/**
 * 账单地
 *
 * @author hzl
 * @date 2020/11/12
 */
public interface AddressMappingDao {

    @Select("select * from address_mapping where jump_id = #{jumpId} order by id")
    @ResultType(AddressMapping.class)
    List<AddressMapping> list(@Param("jumpId") Integer jumpId, Page<AddressMapping> page);

    @Select("select * from address_mapping where jump_id = #{jumpId}")
    @ResultType(AddressMapping.class)
    List<AddressMapping> selectByJumpId(@Param("jumpId") Integer jumpId);

    @Insert("insert into address_mapping(jump_id,register_address_parent,register_address,register_address_type,items,items_datail,join_area_polling,operator,create_time) " +
            "values(#{am.jumpId},#{am.registerAddressParent},#{am.registerAddress},#{am.registerAddressType},#{am.items},#{am.itemsDatail},#{am.joinAreaPolling},#{am.operator},#{am.createTime})")
    void insert(@Param("am") AddressMapping addressMapping);

    @Update("UPDATE address_mapping SET register_address_parent = #{registerAddressParent},register_address = #{registerAddress},register_address_type = #{registerAddressType},items = #{items},items_datail = #{itemsDatail},join_area_polling = #{joinAreaPolling} where id = #{id}")
    void update(AddressMapping addressMapping);

//    @Delete("delete from address_mapping where register_address = #{address} and jump_id = #{jumpId}")
//    void delete(@Param("address") String address, @Param("jumpId") Integer jumpId);


    @Delete("delete from address_mapping where jump_id = #{jumpId}")
    void delete(Integer jumpId);
}
